-
-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Quantize to Reference node #2071
Conversation
Oh yeah, i was going to restrict the reference image type to be a multiple/ratio of the input image, but I couldn't figure that out |
No. That will apply the palette from the entire reference image to the entire target image. That's not what this does. This restricts the palette to just a small area at a time so there's no chance it'll use a color where it's not supposed to. For example if the top third of an image is green colors, the middle third is reds, and the bottom is blues, it might use the green colors from the top section in the bottom blue section if it decides some of the colors are closer (for example if an upscale has color shift or something). That's obviously a bit of an unlikely example, but in something like the image I posted above, you can see how those smooth gradients might end up having different colors from random points of the image, which we want to avoid. |
4070356
to
897dd55
Compare
Maybe |
That's awesome, thanks for playing around and making those changes |
* Add spacial component to local quantization * Typo * Some docs
Is this ready? |
No, I want to rename it to Quantize to Reference. I can't do that right now though, but I'll do it ASAP |
Wait, i can abuse reviews |
backend/src/packages/chaiNNer_standard/image_filter/quantize/quantize_local.py
Outdated
Show resolved
Hide resolved
backend/src/packages/chaiNNer_standard/image_filter/quantize/quantize_local.py
Outdated
Show resolved
Hide resolved
backend/src/packages/chaiNNer_standard/image_filter/quantize/quantize_local.py
Outdated
Show resolved
Hide resolved
Ah damn the file name, can't change that via review :( |
There ya go |
I'm open to calling this node something else because I don't think it's very descriptive called this.
Anyway, this was an idea I had a while back when someone was trying to apply a color palette to an image but keep the colors as close to the original as possible (such as being in the same spots).
I accomplished this by just doing a basic convolution across the original image, taking the unique colors from the kernel, applying the palette to the equivalent piece of the recipient image, and then creating a result from piecing those together. This restricts the possible colors to only the colors that could possibly be in that part of the image, and as a result, manages to index the image pretty well in a way that keeps it faithful.
It's obviously not perfect, but it did what this person wanted more than dither (palette) did.
The biggest downside is it's pretty slow (On^2 time complexity), so maybe this is another good one to move to rust in the future. Alternatively, something could probably be made using the flatten/reshape stuff like the quantizing function does, but I don't wanna have to figure that out lol